<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="file" id="upfile" />
    <button>点击上传</button>
  </body>
  <script>
    var btn = document.getElementsByTagName("button")[0];
    btn.onclick = async function () {
      var url = "http://101.132.72.36:5100/api/upload";
      var inp = document.getElementById('upfile')
      var formData = new FormData()
        formData.append('imagefile',inp.files[0])
        var resp = await fetch(url,{
            method:"POST",
            body:formData//如果请求体为formdata，则会自动将content-typemultipart/form-data
        })
        resp.json().then(res=>{
            console.log(res)
        })
    };
  </script>
</html>
